package cn.edu.scau.cmi.wujiaming.experiment3.controller;

import java.net.URL;
import java.util.ResourceBundle;

import cn.edu.scau.cmi.wujiaming.experiment3.factorymethod.AutomobileDamageFactory;
import cn.edu.scau.cmi.wujiaming.experiment3.factorymethod.DriverInjuredFactory;
import cn.edu.scau.cmi.wujiaming.experiment3.factorymethod.MultipleAccidentsFactory;
import cn.edu.scau.cmi.wujiaming.experiment3.factorymethod.PersonalCasualtyFactory;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextArea;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;

public class FMMController implements Initializable {
	
	@FXML
	private ImageView imageView;
	
	@FXML
	private Button button;
	
	@FXML
	private ComboBox<String> comboBox;
	
	@FXML
	private TextArea textArea;
	
	@Override
	public void initialize(URL arg0, ResourceBundle arg1) {
		// 设置头像
		imageView.setImage(new Image(FMMController.class.getResource(
				"/cn/edu/scau/cmi/wujiaming/myPicture.jpg").toString()));
		// 设置复选框的值
		ObservableList<String> items = FXCollections.
				observableArrayList("司机受伤", "汽车损坏", "人员伤亡", "多种事故");
		comboBox.setItems(items);
	}
	
	public void OnButtonDisplay(ActionEvent event)  {
		String text = "null";
		
		if (comboBox.getValue() != null) {
			switch (comboBox.getValue()) {
			case "司机受伤": 
				text = new DriverInjuredFactory().createInsurance().toString();
				break;
			case "汽车损坏": 
				text = new AutomobileDamageFactory().createInsurance().toString();
				break;
			case "人员伤亡": 
				text = new PersonalCasualtyFactory().createInsurance().toString();
				break;
			case "多种事故":
				text = new MultipleAccidentsFactory().createInsurance().toString();
			}
		}
		textArea.setText(text);
		
		
		
	}
}
